<%@ page import="giit.computerbase.server.ActivityTypeAnalyzation" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Iterator" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>主页</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/site.min.css" rel="stylesheet">

</head>

<body style="background-color: lightcyan">

<!-- page header start-->
<div class="row">
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                        aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="index">主页</a>
            </div>
            <div id="navbar" class="collapse navbar-collapse">
                <ul class="nav navbar-nav navbar-right">
                    <%
                        String user = (String) request.getSession().getAttribute("user");
                        if (user == null || user.equals("")) {
                    %>
                    <li><a href="login.jsp">登录</a></li>
                    <li><a href="register.jsp">注册</a></li>
                    <%
                    } else {
                    %>
                    <li><a href=""><%=request.getSession().getAttribute("user")%>
                    </a></li>
                    <li><a href="edit.jsp">发新闻稿</a></li>
                    <%
                        if ((boolean) request.getSession().getAttribute("manager")) {
                    %>
                    <li><a href="manager.jsp">管理</a></li>
                    <%
                        }
                    %>
                    <li><a href="logout">退出</a></li>
                    <%
                        }
                    %>
                </ul>
            </div><!--/.nav-collapse -->
        </div>
    </nav>
</div>
<!-- page header end-->

<div class="header"
     style="background-image: url(images/bg.jpg)">
    <form action="search" method="post">
        <div class="container">
            <div class="row">
                <div class="col-xs-12">
                    <div class="logotxt">
                        <div class="input-group">
                            <input type="text" class="form-control" placeholder="搜索..." name="title">
                            <span class="input-group-btn">
                <button class="btn btn-default" type="submit">搜索</button>
              </span>
                        </div><!-- /input-group -->
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>

<main class="main" role="main" style="background-color: skyblue">
    <div class="container">
        <div class="row" id="post-list">

            <div class="col-xs-12 col-sm-6">
                <article class="post tag-foreign-website tag-bootstrap-v3">
                    <canvas id="activityType" width="600px" height="900px"></canvas>
                </article>
            </div>

            <div class="col-xs-12 col-sm-6">
                <article class="post tag-foreign-website tag-bootstrap-v3">
                    <canvas id="activityType2" width="600px" height="900px"></canvas>
                </article>
            </div>

        </div>
    </div>
</main>

<div class="submit-site">
    <div class="container">
        <div class="submit">
            <p class="text-center">- Powered by jsly & tum0r -</p>
            <p class="text-center">- 桂林电子科技大学信息科技学院 -</p>
            <p class="text-center">- 信息工程系大学生计算机创新实践基地 -</p>
        </div>
    </div>
</div>

<footer class="main-footer">
    <div class="container">
        <div class="row">
            <div class="col-sm-4">
                <div class="widget">
                    <h4 class="title">友情链接</h4>
                    <div class="content tag-cloud friend-links">
                        <a href="http://www.bootcss.com/" title="Bootstrap中文网" target="_blank">Bootstrap中文网</a>
                        <a href="https://www.jquery123.com/" title="jQuery中文网" target="_blank">jQuery中文网</a>
                        <a href="https://www.golaravel.com/" title="Laravel中文网" target="_blank">Laravel中文网</a>
                    </div>
                </div>
            </div>

            <div class="col-sm-4">
                <div class="widget">
                    <h4 class="title">我们用到的技术</h4>
                    <div class="content tag-cloud">
                        <a href="http://www.bootcss.com/" title="Bootstrap中文网" target="_blank">Bootstrap</a>
                        <a href="https://www.jquery123.com/" title="jQuery中文文档" target="_blank">jQuery</a>
                    </div>
                </div>
            </div>

            <div class="col-sm-4">
                <div class="widget">
                    <h4 class="title">赞助商</h4>
                    <div class="content friend-links">

                    </div>
                </div>
            </div>
        </div>
    </div>
</footer>

<div class="copyright">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <span><a href="http://www.miibeian.gov.cn/" target="_blank">京ICP备xxxxxxx号</a></span>
            </div>
        </div>
    </div>
</div>
<script src="js/Chart.js"></script>
<script src="js/Chart.bundle.js"></script>
<script src="js/Chart.bundle.min.js"></script>
<script src="js/Chart.min.js"></script>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<%
    ActivityTypeAnalyzation activityTypeAnalyzation = new ActivityTypeAnalyzation();
    HashMap<String, Integer> result = activityTypeAnalyzation.getAnalyzation();
    Iterator<String> iterator = result.keySet().iterator();
    String[] typeName = new String[5];
    int[] typeNum = new int[5];
    int index = 0;
    while (iterator.hasNext()) {
        typeName[index] = iterator.next();
        typeNum[index] = result.get(typeName[index]);
        index++;
    }
%>
<script>
    var myRadarData = {
        labels: ["<%=typeName[0]%>", "<%=typeName[1]%>", "<%=typeName[2]%>", "<%=typeName[3]%>", "<%=typeName[4]%>"],
        datasets: [{
            label: "活动类型",
            data: [<%=typeNum[0]%>, <%=typeNum[1]%>, <%=typeNum[2]%>, <%=typeNum[3]%>, <%=typeNum[4]%>],
            backgroundColor: "rgba(244,164,96,0.7)"
        }]
    };

    var ctx = document.getElementById("activityType").getContext("2d");

    new Chart(ctx, {
        type: "radar",
        data: myRadarData,
        options: {
            responsive: true,
            legend: {position: 'top'},
            scale: {ticks: {beginAtZero: true}},
            animation: {animateRotate: false, animateScale: true}
        }
    });

    var myPieData = {
        labels: ["<%=typeName[0]%>", "<%=typeName[1]%>", "<%=typeName[2]%>", "<%=typeName[3]%>", "<%=typeName[4]%>"],
        datasets: [{
            data: [<%=typeNum[0]%>, <%=typeNum[1]%>, <%=typeNum[2]%>, <%=typeNum[3]%>, <%=typeNum[4]%>],
            backgroundColor: ["rgb(255,255,0)", "rgb(255,0,0)", "rgb(0,255,255)", "rgb(0,0,255)", "rgba(0,200,0)"]
        }],
    };


    var ctx2 = document.getElementById("activityType2").getContext("2d");

    new Chart(ctx2, {
        type: "doughnut",
        data: myPieData,
        options: {
            scaleStartValue: 0,
            responsive: true
        }
    });
</script>
</body>
</html>
